package com.lagou.mr.homework1;

import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

public class HomeworkMapper extends Mapper<LongWritable, Text, IntWritable, NullWritable> {

    IntWritable k = new IntWritable();
    NullWritable v = NullWritable.get();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        // 获取一行
        String line = value.toString();

        // 转换为Integer数据类型
        Integer num = Integer.parseInt(line);

        // 输出，IntWritable类型默认为升序排序
        k.set(num);
        context.write(k, v);
    }
}